package cn.iocoder.yudao.module.call.mq.consumer.intention;

import cn.iocoder.yudao.module.call.enums.CallListenActionSourceEnum;
import cn.iocoder.yudao.module.call.mq.message.intention.IntentionMessage;
import cn.iocoder.yudao.module.call.service.ivrintentionlabelstatistics.IvrIntentionLabelStatisticsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 针对 {@link IntentionMessage} 的消费者
 *
 * @author 芋道源码
 */
@Component
@Slf4j
public class IntentionConsumer {


    @Resource
    private IvrIntentionLabelStatisticsService ivrIntentionLabelStatisticsService;


    @EventListener
    @Async // Spring Event 默认在 Producer 发送的线程，通过 @Async 实现异步
    public void onMessage(IntentionMessage message) {
        ivrIntentionLabelStatisticsService.createByCallId(message.getFlowId(), message.getCallId(), message.getMobile(),message.getCallTaskId());

    }

}
